﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestForm
{
    public partial class TC_DATALR : Form
    {

        #region 公布属性

        private int brid=-1;
        public int Brid
        {
            get { return brid; }
            set { brid = value; }
        }

        #endregion

        #region 全局变量

        #endregion

        #region 窗体通用
        public TC_DATALR()
        {
            InitializeComponent();
        }

        private void TC_DATALR_Load(object sender, EventArgs e)
        {
            //控制日期或时间的显示格式
            this.dateTimePicker1.CustomFormat = "yyyy-MM-dd";
            //使用自定义格式
            this.dateTimePicker1.Format = DateTimePickerFormat.Custom;

            //控制日期或时间的显示格式
            this.dtpSJSJ.CustomFormat = "HH:mm";
            //使用自定义格式
            this.dtpSJSJ.Format = DateTimePickerFormat.Custom;
        }
        #endregion

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.brid == -1)
            {
                MessageBox.Show("请选择病人");
                return;
            }
            else
            {
                string xmlData = string.Empty;
                xmlData = "<DATA>";
                xmlData += "<TC>";
                xmlData += "<BRID>" + this.brid + "</BRID>";
                xmlData += "<RQ>" + this.dateTimePicker1.Text + "</RQ>";
                xmlData += "<LRSJ>" + this.comboBox1.Text + "</LRSJ>";

                xmlData += "<SG>"+this.txtSG.Text+"</SG>";//身高
                xmlData += "<TZ>" + this.txtTZ.Text + "</TZ>";
                xmlData += "<RL>" + this.txtRL.Text + "</RL>";
                xmlData += "<CL>" + this.txtCL.Text + "</CL>";
                xmlData += "<NL>" + this.txtNL.Text + "</NL>";
                xmlData += "<XY>" + this.txtXY.Text + "</XY>";
                xmlData += "<DBCS>" + this.cbxDBCS.Text + "</DBCS>";
                xmlData += "<PSXX>" + this.txtPSXX.Text + "</PSXX>";
                xmlData += "<PSJG>" + this.cbxPSJG.Text + "</PSJG>";

                xmlData += "<TW>" + this.txtTW.Text + "</TW>";
                xmlData += "<TWBW>" + this.cbxTWBW.Text + "</TWBW>";
         
                xmlData += "<MB>" + this.txtMB.Text + "</MB>";
                xmlData += "<HX>" + this.txtHX.Text + "</HX>";
                xmlData += "<XL>" + this.txtHX.Text + "</XL>";
                xmlData += "<WLJW>" + this.txtWLJW.Text + "</WLJW>";

                xmlData += "<SJ>" + this.cbxSJ.Text + "</SJ>";
                xmlData += "<SJSJ>" + this.dtpSJSJ.Text + "</SJSJ>";

                if (rbJJ.Checked)
                {
                    xmlData += "<JCWC>" + "拒测" + "</JCWC>";
                }
                else if (rbWC.Checked)
                {
                    xmlData += "<JCWC>" + "外出" + "</JCWC>";
                }
                if (ckbHXJ.Checked)
                {
                    xmlData += "<HXJ>" + "1" + "</HXJ>";
                }
                else
                {
                    xmlData += "<HXJ>" + "0" + "</HXJ>";
                }
                if (ckbSFFH.Checked)
                {
                    xmlData += "<SFFH>" + "1" + "</SFFH>";
                }
                else
                {
                    xmlData += "<SFFH>" + "0" + "</SFFH>";
                }
                xmlData += "</TC>";
                xmlData += "</DATA>";

                string sql="exec USP_TC_SAVE '"+xmlData+"'";
                DataTable dtResult = SqlHelper.ExecuteDataSet(CommandType.Text, sql).Tables[0];
                if (dtResult.Rows[0][0].ToString() == "T")
                {
                    MessageBox.Show("体温数据保存成功");
                }
                else
                {
                    MessageBox.Show("体温数据保存失败");
                }
            }
        }

        #region 业务流程

        #endregion
       
    }
}
